(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/mouse.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'aa6c267ChhP24Iw77pj/rWb', 'mouse', __filename);
// Script/mouse.js

"use strict";

var _backgrould = require("./backgrould");

var _backgrould2 = _interopRequireDefault(_backgrould);

var _allVariable = require("./allVariable");

var _allVariable2 = _interopRequireDefault(_allVariable);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

cc.Class({
    extends: cc.Component,

    properties: {

        sprArray: {
            default: [],
            type: [cc.SpriteFrame]
        },
        spineBoom: cc.Node,
        starBoom: cc.Node,
        locationNum: cc.Integer,
        kindmouseNum: cc.Integer,
        giftLayout: cc.Node,
        mousebutton: cc.Button,
        backgroudJs: _backgrould2.default,
        audio: {
            default: null,
            type: cc.AudioClip
        },
        clickOneaudio: {
            default: null,
            type: cc.AudioClip
        },
        clickTwoaudio: {
            default: null,
            type: cc.AudioClip
        },
        clickThreeaudio: {
            default: null,
            type: cc.AudioClip
        },
        switchSound: {
            default: null,
            type: cc.AudioClip
        },

        appearSoundOne: {
            default: null,
            type: cc.AudioClip
        },

        appearSoundTwo: {
            default: null,
            type: cc.AudioClip
        },
        appearSoundThree: {
            default: null,
            type: cc.AudioClip
        },

        appearSwitchSound: {
            default: null,
            type: cc.AudioClip
        },
        hedgehogSound: {

            default: null,
            type: cc.AudioClip
        },

        boomMouseSound: {
            default: null,
            type: cc.AudioClip
        },

        iconIndex: cc.Integer,
        clickVoice: 0,
        appearVoice: 0

    },

    onLoad: function onLoad() {

        var spineBoomNode = cc.find("Canvas/backgroundtop/spineBoom");

        this.spineBoom = spineBoomNode;

        this.starBoom = cc.find("Canvas/backgroundtop/spinnormal");
    },


    clickMouse: function clickMouse(event) {

        if (_allVariable2.default.SourceChange == true) {

            cc.audioEngine.stop(this.current);
        } else {

            if (this.kindmouseNum == 6) {

                this.current = cc.audioEngine.play(this.hedgehogSound, false, 1);
            } else if (this.kindmouseNum == 5) {

                this.current = cc.audioEngine.play(this.boomMouseSound, false, 1);
            } else {

                switch (this.clickVoice) {

                    case 0:
                        this.switchSound = this.clickOneaudio;
                        break;

                    case 1:
                        this.switchSound = this.clickTwoaudio;
                        break;

                    case 2:
                        this.switchSound = this.clickThreeaudio;
                        break;

                    default:
                        this.switchSound = this.clickThreeaudio;
                        break;
                }

                this.current = cc.audioEngine.play(this.switchSound, false, 1);
            }
        }
        var templocation = event.getLocation();

        this.backgroudJs.getComponent("backgrould").chuiziGetpointClick(templocation);

        if (this.kindmouseNum == 9) {} else {
            this.mousebutton.interactable = false;
        }

        switch (this.kindmouseNum) {

            case 0:

                this.starAnimates();

                break;

            case 1:

                this.timeAnimates();

                break;

            case 2:

                this.chuiziAnimates();

                break;

            case 3:

                this.coinAnimates();

                break;

            case 4:

                this.waterAnimates();

                break;

            case 5:

                this.boomAnimates();

                break;

            case 6:

                this.hurtAnimates();

                break;

            case 7:

                this.lucencyMouse();

                break;

            case 8:

                this.waterMouse();

                break;

            case 9:

                this.ironMouse();

                break;

            default:
                this.otherMouse;

                break;

        }
    },

    otherMouse: function otherMouse() {
        console.log("其他地鼠");
    },

    lucencyMouse: function lucencyMouse() {

        console.log("透明地鼠");
        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        this.starBoom.getComponent("starboom").init(this.locationNum);

        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 1);
        this.giftLayout.setContentSize(84, 50);
        this.giftAddAnimates();
        var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
        timeshowNode.getComponent("socreShow").addCoinStarNumber();
    },

    waterMouse: function waterMouse() {

        console.log("水盆地鼠");

        var isEexitArray = _allVariable2.default.waterMouseNsArray.indexOf(this.node);

        if (isEexitArray >= 0) {

            _allVariable2.default.waterMouseNsArray.splice(isEexitArray, 1);

            this.node.resumeAllActions();

            var hideAction = cc.hide();
            this.node.runAction(hideAction);

            this.starBoom.getComponent("starboom").init(this.locationNum);
        } else {

            console.log("水地鼠不在数组里面");
        }
    },

    ironMouse: function ironMouse() {

        if (_allVariable2.default.isUseHammer) {

            var hideAction = cc.hide();
            this.node.runAction(hideAction);
            this.mousebutton.interactable = false;

            this.giftLayout.getComponent("giftlayout").init(this.locationNum, 4);
            this.giftLayout.setContentSize(84, 50);
            this.giftAddAnimates();
            var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
            timeshowNode.getComponent("socreShow").addMoreCoinStarNumber();
        } else {

            this.iconIndex = this.iconIndex + 1;

            console.log("铁头地鼠", this.iconIndex);
            var that = this;
            switch (this.iconIndex) {

                case 1:

                    cc.loader.loadRes("帽子地鼠1", cc.SpriteFrame, function (err, spriteFrame) {
                        that.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                    });

                    break;

                case 2:

                    cc.loader.loadRes("帽子地鼠2", cc.SpriteFrame, function (err, spriteFrame) {
                        that.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                    });
                    break;

                case 3:

                    cc.loader.loadRes("帽子地鼠3", cc.SpriteFrame, function (err, spriteFrame) {
                        that.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                    });
                    break;

                case 4:

                    var hideAction = cc.hide();
                    this.node.runAction(hideAction);
                    this.starBoom.getComponent("starboom").init(this.locationNum);
                    this.mousebutton.interactable = false;

                    this.giftLayout.getComponent("giftlayout").init(this.locationNum, 4);
                    this.giftLayout.setContentSize(84, 50);
                    this.giftAddAnimates();
                    var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
                    timeshowNode.getComponent("socreShow").addMoreCoinStarNumber();

                    break;

                default:
                    break;

            }
        }
    },

    //   // 1
    starAnimates: function starAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        if (_allVariable2.default.isUseHammer) {
            console.log("地鼠星星动画");
        } else {
            this.starBoom.getComponent("starboom").init(this.locationNum);
        }
        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 4);
        this.giftLayout.setContentSize(84, 50);
        this.giftAddAnimates();
        var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
        timeshowNode.getComponent("socreShow").addMoreCoinStarNumber();
    },

    //   // 2
    timeAnimates: function timeAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        if (_allVariable2.default.isUseHammer) {
            console.log("地鼠时间动画");
        } else {
            this.starBoom.getComponent("starboom").init(this.locationNum);
        }
        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 6);
        this.giftLayout.setContentSize(119, 51);
        this.giftAddAnimates();
        var timeshowNode = cc.find("Canvas/topsprite/timeshow");
        timeshowNode.getComponent("timeShow").addTimePropNumber();
    },

    //   // 3
    chuiziAnimates: function chuiziAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        if (_allVariable2.default.isUseHammer) {
            console.log("地鼠锤子动画");
        } else {
            this.starBoom.getComponent("starboom").init(this.locationNum);
        }
        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 2);
        this.giftLayout.setContentSize(85, 55);
        this.giftAddAnimates();
        _allVariable2.default.chuiziCount = _allVariable2.default.chuiziCount + 1;
        var chuizishowNode = cc.find("Canvas/chuiziBtn");
        chuizishowNode.getChildByName("hammerPropShow").getChildByName("hammerPropLabel").getComponent("NumberView").setText(_allVariable2.default.chuiziCount);
    },

    //   // 4
    coinAnimates: function coinAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        if (_allVariable2.default.isUseHammer) {
            console.log("金币动画");
        } else {
            this.starBoom.getComponent("starboom").init(this.locationNum);
        }
        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 0);
        this.giftLayout.setContentSize(83, 49);
        this.giftAddAnimates();
        _allVariable2.default.wawaCoinAddNumber = _allVariable2.default.wawaCoinAddNumber + 1;
    },

    //   // 5
    waterAnimates: function waterAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);
        if (_allVariable2.default.isUseHammer) {
            console.log("正常地鼠");
        } else {
            this.starBoom.getComponent("starboom").init(this.locationNum);
        }

        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 1);
        this.giftLayout.setContentSize(84, 50);
        this.giftAddAnimates();
        var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
        timeshowNode.getComponent("socreShow").addCoinStarNumber();
    },

    //   // 6
    boomAnimates: function boomAnimates() {

        var hideAction = cc.hide();
        this.node.runAction(hideAction);

        if (_allVariable2.default.isUseHammer) {
            console.log("地鼠捧雷动画");
        } else {

            this.spineBoom.getComponent("boom").init(this.locationNum);
        }
        this.giftLayout.getComponent("giftlayout").init(this.locationNum, 5);
        this.giftLayout.setContentSize(110, 50);
        this.giftAddAnimates();
        var timeshowNode = cc.find("Canvas/topsprite/scoreShow");
        timeshowNode.getComponent("socreShow").minusStarNumber();

        var miusstarNode = cc.find("Canvas/topsprite/boommius/miusstarNumber");

        miusstarNode.getComponent("NumberView").setLeftText(10, true);

        miusstarNode.active = true;

        var changebig2 = cc.scaleTo(0.2, 1.1);

        var changesmail2 = cc.scaleTo(0.1, 1.0);

        var delayAction = cc.delayTime(2);

        var finish = cc.callFunc(function () {

            miusstarNode.active = false;
            console.log("减分标志消失");
        }, this);

        var seq = cc.sequence(changebig2, changesmail2, delayAction, finish);

        miusstarNode.runAction(seq);
    },

    //   // 7
    hurtAnimates: function hurtAnimates() {

        console.log("地鼠刺猬动画");
        var that = this;
        cc.loader.loadRes("刺猬地鼠2", cc.SpriteFrame, function (err, spriteFrame) {
            that.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });
        if (_allVariable2.default.isUseHammer) {

            var hideAction = cc.hide();
            this.node.runAction(hideAction);
        } else {
            this.backgroudJs.getComponent("backgrould").showhurtAnimates();
        }
    },

    giftAddAnimates: function giftAddAnimates() {

        this.giftLayout.stopAllActions(); //停止
        this.giftLayout.active = true;
        var giftpoint = this.giftLayout.getPosition();
        var action = cc.moveTo(0.5, giftpoint.x, giftpoint.y + 80);

        var finish = cc.callFunc(function () {

            this.giftLayout.active = false;
            this.giftLayout.y = giftpoint.y;
        }, this);

        var seq = cc.sequence(action, finish);
        this.giftLayout.runAction(seq);
    },

    onDestroy: function onDestroy() {

        cc.audioEngine.stop(this.current);
    },

    init: function init(type, locationMouse) {

        if (_allVariable2.default.SourceChange == true) {

            cc.audioEngine.stop(this.appearSound);
        } else {

            switch (this.appearVoice) {

                case 0:
                    this.appearSwitchSound = this.appearSoundOne;
                    break;

                case 1:
                    this.appearSwitchSound = this.appearSoundTwo;
                    break;

                case 2:
                    this.appearSwitchSound = this.appearSoundThree;
                    break;

                default:
                    this.appearSwitchSound = this.appearSoundOne;
                    break;
            }

            this.appearSound = cc.audioEngine.play(this.appearSwitchSound, false, 1);
        }

        // console.log("地鼠种类",type)
        this.node.getComponent(cc.Sprite).spriteFrame = this.sprArray[type];

        this.node.active = true;

        this.locationNum = locationMouse;

        this.kindmouseNum = type;

        this.mousebutton.interactable = true;
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=mouse.js.map
        